//
//  ViewController.m
//  UI07_UINavigationController
//
//  Created by aaaaaa on 16/6/14.
//  Copyright © 2016年 dllo. All rights reserved.
//

#import "ViewController.h"
#import "SecondViewController.h"

@interface ViewController ()

@end

@implementation ViewController

- (void)viewWillAppear:(BOOL)animated{
    NSLog(@"%d, %s", __LINE__, __FUNCTION__);
//    self.navigationController.navigationBarHidden = NO;

}

- (void)viewWillDisappear:(BOOL)animated{
    NSLog(@"%d, %s", __LINE__, __FUNCTION__);
}

- (void)viewDidAppear:(BOOL)animated{
    NSLog(@"%d, %s", __LINE__, __FUNCTION__);
}

- (void)viewDidDisappear:(BOOL)animated{
    NSLog(@"%d, %s", __LINE__, __FUNCTION__);
}



- (void)viewDidLoad {
    [super viewDidLoad];

    self.view.backgroundColor = [UIColor whiteColor];
    
    
    /**设置导航栏的标题**/
    self.title = @"首页";
    [self configNavigationItem];
    [self configNavigationBar];
}

#pragma mark - UINavigationItem
- (void)configNavigationItem{
    self.navigationItem.title = @"First";
    
    /**设置导航栏右边的按钮**/
    self.navigationItem.rightBarButtonItem = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemDone target:self action:@selector(rightAction:)];
    
    self.navigationItem.leftBarButtonItem = [[UIBarButtonItem alloc] initWithImage:[UIImage imageNamed:@"weixin.png"] style:UIBarButtonItemStylePlain target:self action:@selector(leftAction:)];
}

- (void)rightAction:(UIBarButtonItem *)item{
    NSLog(@"导航栏右边Item");
    SecondViewController *secondVc = [[SecondViewController alloc] init];
    
    /*此时secondVC被加入到navigationController的viewControllers数组中，引用计数加1*/
    [self.navigationController pushViewController:secondVc animated:YES];
    [secondVc release];
}

- (void)leftAction:(UIBarButtonItem *)item{
    NSLog(@"导航栏左边Item");
}

#pragma mark - UINavigationBar
- (void)configNavigationBar{
    //Item的颜色
    self.navigationController.navigationBar.tintColor = [UIColor whiteColor];
    
    //导航栏的颜色
//    self.navigationController.navigationBar.barTintColor = [UIColor colorWithRed:31 / 255.0 green:174 / 255.0 blue:244 / 255.0 alpha:1.0];
    
    //背景颜色
    self.navigationController.navigationBar.backgroundColor = [UIColor redColor];
    
    //设置标题颜色和大小
    self.navigationController.navigationBar.titleTextAttributes = @{
                                                                    NSForegroundColorAttributeName:[UIColor redColor],
                                                                    NSFontAttributeName:[UIFont systemFontOfSize:20]
                                                                    };
}



- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

@end
